Often, applications share common functions. For example, a voice recorder application and a voice communication application both require a voice codec function. One way to permit both applications to have access to the same function is to employ shared libraries.
Shared libraries are collections of sub-programs that are shared among multiple programs. The multiple programs can simultaneously run the shared libraries, and thus shared libraries provide some advantages to programmers. However, some operating systems require shared libraries to always be resident in internal memory. In many computing systems, internal memory is a limited resource. When shared libraries are used, the limited resource (e.g. internal memory) becomes even more limited.
Shared libraries need to be reentrant. Their design imposes the reentrancy requirement because shared libraries use the addressing context of the calling program. Due to this, shared libraries execute in different virtual address spaces which they inherit from the calling program.
An alternative to shared libraries is to declare a full copy of the exact same function (e.g., declaring the memory map, input source files, etc.) in each application. Once declared in each application, the function can be overlapped, i.e., the same source code in memory can be used by each calling application.
Declaring the same function in each application and overlapping them has drawbacks, such as maintenance and wasted memory. For example, it is difficult to maintain the memory map because care has to be taken to ensure that any changes (such as, adding a new data variable to the function) are reflected across all functions. It is also error prone to remove the function's memory map from applications that no longer need the function. Moreover, each function requires its own data structures to enable the overlapping, and finally, extra memory is allocated toward each function.
It would be beneficial if multiple applications could more efficiently share the same copy of source code for a called function without needing to make the function reentrant.